package com.zjmzxfzhl.modules.purchase.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 【】实体类
 *
 * @author 庄金明
 */
@Getter
@Setter
@TableName("T_PURCHASE_PAYMENT")
public class PurchasePayment {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @NotNull
    private Long id;

    /**
     * 所属合同id
     */
    @NotNull

    private Long contractId;

    /**
     * 付款单编号
     */
    @NotNull
    private String paymentCode;

    /**
     * 比例
     */
    @NotNull
    private BigDecimal proportion;

    /**
     * 付款金额
     */
    @NotNull
    private BigDecimal payAmount;

    private Boolean editAmount;

    /**
     * 付款日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date paymentDate;

    /**
     * 付款审批状态
     */
    private String paymentApprovalState;

    /**
     * 付款情况
     */
    private String paymentSituation;

    /**
     * 备注
     */
    private String paymentComment;


    @Override
    public String toString() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return proportion + "% " + (paymentDate == null ? "" : sdf.format(paymentDate)) + " " + paymentApprovalState + " " + paymentSituation + " " + paymentComment;
    }

    public PurchasePayment() {

    }

    public PurchasePayment(Long contractId) {
        this.contractId = contractId;
    }
}
